﻿@{
    Layout = null;
}
<script type="text/javascript">
    $(function () {
        $("#rptList").datagrid({
            url: "Classes/List?r=" + Math.random(),
            onRowContextMenu: function (e, rowindex, rowData) {
                $("#rptList").datagrid('selectRow', rowindex);
                e.preventDefault();
                var row = $("#rptList").datagrid('getSelected');
                if (row) {
                    $('#menuClasses').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                }
            }

        });
    });
    function Delete() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            $.messager.confirm('提醒', '<br>确定要删除' + row.ClassName + '这个班级吗?', function (r) {
                if (r) {
                    form1.action = "Classes/Delete/" + row.Id;
                    $('#loading').window('open');
                    $("#form1").ajaxSubmit({ action: this.action, method: this.method });
                }
            });
        } else {
            $.messager.alert('错误', '<br>请先选择要删除的数据！', 'error');
        }
    }
    function Edit() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            $('#divAdd').window('open').panel({ href: 'Classes/Edit/' + row.Id });
        } else {
            $.messager.alert('错误', '<br>请先选择要编辑的数据！', 'error');
        }
    }
    function Student() {
        var row = $("#rptList").datagrid('getSelected');
        if (row) {
            TreeLink('Student/Index/' + row.Id, '学生管理');
        } else {
            $.messager.alert('错误', '<br>请先选择一个班级！', 'error');
        }
    }
    function RequestError() {
        $.messager.alert('错误', '<br>请求失败！', 'error');
    }
</script>
<form id="form1" action="Classes/Delete" method="post" data-ajax-failure="RequestError"
data-ajax="true">
<div style="padding: 10px;">
    <table id="rptList" class="easyui-datagrid" width="100%" cache="false" title="Load Data"
        singleselect="true" toolbar="#tb" iconcls="icon-save" rownumbers="true" pagination="true"
        pagelist="[10,20,25,30]">
        <thead>
            <tr>
                <th field="Id" width="50" align="center" hidden="true">
                    Id
                </th>
                <th field="ClassName" width="100" align="center">
                    班级名称
                </th>
                <th field="ClassTeacher" width="100" align="center">
                    班主任
                </th>
                <th field="StudentNum" width="100" align="center" >
                    学生人数
                </th>
            </tr>
        </thead>
    </table>
</div>
<div id="tb" style="height: auto">
    <div style="padding: 5px; height: 26px;">
        <a href="javascript:$('#divAdd').window('open').panel({href:'Classes/Create'});" class="easyui-linkbutton"
            style="float: left;" iconcls="icon-add" plain="true">新增</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0)" onclick="Edit();" class="easyui-linkbutton" style="float: left;"
            iconcls="icon-edit" plain="true">编辑</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-cut"
            plain="true" onclick="javascript:Delete();">删除</a>
        <div class="dialog-tool-separator">
        </div>
        <a href="javascript:void(0);" class="easyui-linkbutton" style="float: left;" iconcls="icon-save"
            plain="true" onclick="javascript:Student();">学生管理</a>
    </div>
</div>
<div id="menuClasses" class="easyui-menu" style="width: 120px;">
    <div iconcls="icon-edit" onclick="javascript:Edit();">
        编辑</div>
    <div class="menu-sep">
    </div>
    <div iconcls="icon-remove" onclick="javascript:Delete()">
        删除</div>
    <div class="menu-sep">
    </div>
    <div iconcls="icon-save" onclick="javascript:Student()">
        学生管理</div>
</div>
<div id="divAdd" class="easyui-window" resizable="false" title="新增班级" minimizable="false" cache="false"
            modal="true" closed="true" dosize="false" collapsible="false" maximizable="false"
            style="width: 400px; height: 170px; padding-top: 10px; text-align: center;">
</div>
</form>
